package com.main.exception;

import com.main.common.Response;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(TooFrequentRequestException.class)
    @ResponseStatus(HttpStatus.TOO_MANY_REQUESTS)
    @ResponseBody
    public Response handleTooFrequentRequestException(TooFrequentRequestException ex) {
        return Response.failure(HttpStatus.TOO_MANY_REQUESTS, ex.getMessage());
    }

    // 可以添加其他异常处理方法...
}
